home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Information / Digests / CSMP Digest / volume 1 / csmp-v1-154.txt < prev    next >
Encoding:
Text File  |  1994-12-08  |  48.4 KB  |  1,142 lines  |  [TEXT/R*ch]

  1. C.S.M.P. Digest             Mon, 03 Aug 92       Volume 1 : Issue 154
  2.  
  3. Today's Topics:
  4.  
  5.     The Bedrock White Paper
  6.     Does the 68000 have a "block move" instruction
  7.  
  8.  
  9.  
  10. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  11.  
  12. The digest is a collection of article threads from the internet newsgroup
  13. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  14. regularly and want an archive of the discussions.  If you don't know what a
  15. newsgroup is, you probably don't have access to it.  Ask your systems
  16. administrator(s) for details.  (This means you can't post questions to the
  17. digest.)
  18.  
  19. Each issue of the digest contains one or more sets of articles (called
  20. threads), with each set corresponding to a 'discussion' of a particular
  21. subject.  The articles are not edited; all articles included in this digest
  22. are in their original posted form (as received by our news server at
  23. cs.uoregon.edu).  Article threads are not added to the digest until the last
  24. article added to the thread is at least one month old (this is to ensure that
  25. the thread is dead before adding it to the digest).  Article threads that
  26. consist of only one message are generally not included in the digest.
  27.  
  28. The entire digest is available for anonymous ftp from ftp.cs.uoregon.edu
  29. [128.223.8.8] in the directory /pub/mac/csmp-digest.  The most recent issues
  30. are available from sumex-aim.stanford.edu [36.44.0.6] in the directory
  31. /info-mac/digest/csmp.  If you don't have ftp capability, the sumex archive
  32. has a mail server; send a message with the text '$MACarch help' (no quotes)
  33. to LISTSERV@ricevm1.rice.edu for more information.
  34.  
  35. The digest is also available via email.  Just send a note saying that you
  36. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  37. automatically receive each new issue as it is created.  Sorry, back issues
  38. are not available through the mailing list.
  39.  
  40. Send administrative mail to mkelly@cs.uoregon.edu.
  41.  
  42.  
  43. -------------------------------------------------------
  44.  
  45. From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
  46. Subject: The Bedrock White Paper
  47. Organization: Kalamazoo College
  48. Date: Wed, 24 Jun 1992 16:12:48 GMT
  49.  
  50.  
  51. The Bedrock (tm) Cross-Platform Application Framework
  52. A White Paper
  53.  
  54.  
  55. I. Introduction
  56. The Bedrock framework is a cross-platform application framework technology.  It
  57. assists application developers in (1) creating applications of high quality and
  58. reliability, (2) quickly delivering these applications across industry standard
  59. platforms, and (3) localizing these applications to meet the specific
  60. requirements of each country.  The Bedrock framework accomplishes these
  61. objectives by taking advantage of object-oriented technology to provide the
  62. developer a reusable components approach to building applications.  Components
  63. supplied by the Bedrock Framework can be used to build sophisticated Graphical
  64. User Interface (GUI) based applications that are tuned to the specific platform
  65. GUI.  In addition, the developer may create new components which can be used
  66. and shared among multiple development efforts.  These components, built on top
  67. of the Bedrock framework, are portable across the same platforms as the Bedrock
  68. framework.  They provide the developer a leveraged productivity tool for use in
  69. building and maintaining new applications.
  70.  
  71. II.Background
  72. What is an Application Framework?
  73. Building GUI based applications on todayUs platforms is a difficult chore.  The
  74. small task of placing a window on the screen requires the application developer
  75. to deal with, and coordinate, a large number of system services; the window
  76. manager, the event manager, the memory manager, etc.  The application
  77. programming interface (API) to these systems are low level, meaning that it
  78. takes a large effort to accomplish what seems to be a simple task.  Changing
  79. the pre-defined behavior of the standard services for an application is
  80. difficult.  And the problem is further complicated when trying to support
  81. multiple platforms.  The goal of an application framework is to provide the
  82. developer a Rstructure" with functionality common to most applications.  The
  83. developer than adds to this RstructureS the specific functionality required to
  84. complete the application.  Creating new types of applications is an incremental
  85. effort.
  86.  
  87. The initial value of an application framework is in the head start it provides.
  88. It automatically provides the structure for the application to create the
  89. application desktop, provide default menus, and handle the interactions between
  90. the application and the operating system.  Having this initial structure
  91. available makes it easier to create the RHello WorldS in a window example.
  92. Bedrock requires 30 lines of code, the Windows API requires over 100.  Yet,
  93. this is not where the real value of an application framework is delivered.
  94. Because of the overhead of the application framework structure, RHello WorldS
  95. done using an application framework may be easier than using an API, but is
  96. more costly in terms of size of the application.  However, the RHello WorldS
  97. applications are not the ones that developers are building.  They are building
  98. applications with interactive graphical user interfaces.  It is for these kinds
  99. of applications that a developer uses an application framework.  The framework
  100. assists the developer in providing a way of writing application by extending
  101. the structure.  Instead of having to recreate the structure necessary for each
  102. new feature, an application framework allows the developer to reuse the
  103. provided structure, and extend it to implement the new feature.  As
  104. applications grow larger, this ability to extend functionality by incremental
  105. effort lessens the complexity of the application.  This makes it easier to
  106. develop large-scale reliable applications.
  107.  
  108. MacApp, Think C Library (TCL) and ObjectWindowLibrary are all examples of
  109. application frameworks.  They are used by thousands of developers today.
  110. Photoshop from Adobe and SoundEdit Pro from MacroMedia were developed using
  111. MacApp.  Daymaker from Pastel Development and 1-2-3 from Lotus were developed
  112. using TCL.
  113.  
  114. What is a Cross-Platform Application Framework?
  115. Application frameworks such as Apple's MacApp for the Macintosh are targeted at
  116. specific platforms.  Applications written in MacApp will not work on Windows,
  117. and applications written in a Windows application framework will not work on
  118. the Macintosh.  Bedrock uses object-oriented technology to insulate the
  119. developer from the specifics of the platform specific programming interface.
  120. The developer works with high-level abstract components such as Documents,
  121. Panes and Menus.  The developer may have access to even higher level components
  122. such as a drawing tool or text editing engine.  The Bedrock framework then maps
  123. those abstract objects to the platform specific functionality, thus ensuring
  124. cross-platform performance.
  125.  
  126. The developer benefits from a cross-platform application framework in these
  127. significant ways: (1) Less effort to deliver and maintain applications across
  128. multiple platforms, (2) Reduced risk of choosing the wrong platform, and (3)
  129. Providing applications tuned to the platform GUI.
  130.  
  131. What other support should an Application Framework provide?
  132. The United States represents less than 50% of the global software market.
  133. Companies need to deliver applications globally, and commercial developers need
  134. to be able to easily provide common applications in many languages.  In order
  135. to accomplish this, an application framework needs complete support for
  136. software internationalization.  This should include support for different
  137. character sets, understanding of country and language specific formatting for
  138. date, time and currency, and proper sorting algorithms.
  139.  
  140. III.   The Bedrock Foundation
  141. The Bedrock Framework
  142. The Bedrock framework is a cross-platform application framework technology
  143. implemented in C++.  Specific implementations are being developed today for the
  144. Macintosh and Windows platforms, with others to follow.  There are three major
  145. elements to the Bedrock Framework:  (1) the Bedrock Class Library, (2) Bedrock
  146. Resource Information and the (3) Bedrock Utility Manager.  The Bedrock Class
  147. Library provides the developer with components to build an application.
  148. Bedrock Resource Information provides the developer a platform independent
  149. description of resource information, such as view positioning, dialogs, and
  150. screen for the application.  This resource information is portable across
  151. platforms.  The Bedrock Utility Manager provides the application developer
  152. platform independent access to platform specific services such as memory
  153. management, file management, international information, and time and date
  154. support.
  155.  
  156. The Bedrock Class Library
  157. The Bedrock Class Library is implemented in the industry standard C++.  The
  158. present implementation of the Bedrock Class Library consists of over 150
  159. classes, or types of components that can be used as building blocks by the
  160. application developer.  The Bedrock framework is being implemented using the
  161. class library approach, instead of creating a flat API to provide the developer
  162. more flexibility.  Due to the power of C++, the application developer can
  163. create new components by refining an available component, or combining a number
  164. of available components.  For example, a ValidatedField is a component which
  165. checks input before returning it to an application.  A NumberField is a
  166. refinement of ValidatedField.  A NumberField only accepts numeric characters as
  167. input.  A DateField only accepts valid dates as input.  An application
  168. developer could create another refinement of a ValidatedField for inputting
  169. specific format of accounts within a company.  Once this new component is
  170. developed it can be used and reused and shared among developers.
  171. The Bedrock Class Library supplies the developer a robust set of components for
  172. working with data structures, drawing objects, graphic tools, controls,
  173. windows, streams.  The following are example components in each area:
  174.  
  175.    Functional Area Example Components
  176.    %  Collections  Arrays, Matrices, Sets, ...
  177.    %  Draw objects Rectangle, Ellipses, Polygons, ...
  178.    %  Graphics Tools   Fonts, Pens, Wallpaper, ...
  179.    %  Controls CheckBoxes, RadioButtons, ListBoxes, ...
  180.    %  Windows  Documents, Dialog Boxes, ClipboardWindows, ...
  181.    %  Streams  Files, MemoryStreams, TextStreams, ...
  182.  
  183. The Bedrock Class Library provides an abstraction of the platform-specific
  184. systems functions.  This abstraction frees the developer from worrying about
  185. the specifics of each platform.  The developer works with a Bedrock class, such
  186. as SelectFileDialog.  The class library handles the proper mapping of the
  187. capability to the platform.  The Bedrock Class Library includes a set of
  188. components that handle a Rchain of commandS event processing in a unified way,
  189. regardless of the underlying platform.  Direct calls to the programming
  190. interface are rarely necessary.  This level of abstraction provided by the
  191. class library ensures that the developer will not have to take a Rleast common
  192. denominatorS approach.
  193.  
  194. Bedrock Resource Information
  195. Bedrock Resource Information provides a powerful definition language for
  196. describing menus, dialogs, strings, and accelerator tables.  Any visual
  197. component may be loaded from a resource.  The language also describes custom
  198. visual information defined by the application developer.   The advantage of
  199. separating the resource information from the application code is that
  200. applicationUs visual components can be modified without access to the source
  201. code of the application.  Thus changes to the applicationUs visual components
  202. can be made without having to recompile the application, saving time and
  203. effort.
  204.  
  205. Bedrock Resource Information provides full scripting support and templates for
  206. data description.  The compiler for the information includes a full ANSI C
  207. preprocessor with optional C++ extensions.  This allows the application
  208. developer to create and use macros, and define conditional compilation.  The
  209. information format supports and extends AppleUs Rez, including type
  210. definitions.  Types can be defined by extension, and types can be defined
  211. recursively. Bedrock Resource Information provides support for the entire
  212. visual aspect of user interface in a platform independent way.
  213.  
  214. The Bedrock Utility Manager
  215. The Bedrock Utility Manager supplies a set of platform utilities in a platform
  216. independent manner:
  217.  
  218. Virtual Memory Manager Q allocates and manages memory, provides compaction,
  219. relocation and page swapping capabilities.
  220.  
  221. File Manager Q provides access to the file system including network access and
  222. name handling from partial specifications.
  223.  
  224. String Manager Q provides standard string functions, connected to the
  225. international manager for country-specific processing.  Provides conversion
  226. routines.
  227.  
  228. Date/Time Manager Q provides standard date and time manipulation, tied to the
  229. international manager for country specific processing.
  230.  
  231. International Manager Q provides complete, specific, country, language and code
  232. page information.  This includes formatting information for numbers, currency,
  233. date and time.  Provides support for single-, double-, and multiple-byte
  234. character sets.
  235.  
  236. Validation Manager Q provides string validation for numbers, date, time and
  237. keywords and range and series validation for numbers
  238.  
  239. IV.Future Directions
  240. The Bedrock framework is presently being used for internal application
  241. development at Symantec.  In addition, Symantec is making early versions of the
  242. Bedrock framework available to corporate developers and Independent Software
  243. Vendors.  The information being learned from these efforts is helping Symantec
  244. to understand the market requirements and enabling a refinement of the
  245. technology.
  246.  
  247. In addition, we have announced a development and marketing agreement with Apple
  248. Computer, Inc.  Apple will contribute engineering resources and the Bedrock
  249. framework will leverage the Apple MacApp object-oriented framework technology.
  250. We are also actively seeking other partnerships that will benefit the developer
  251. using the Bedrock framework.
  252.  
  253. The results of these partnerships will be reflected in the quality and the
  254. robustness of the Bedrock framework and will provide the developer a standard
  255. cross-platform application frameworks for all major desktop platforms.
  256.  
  257.  
  258. Developer Support: Developer Services: Tools & Apps: Cross-Platform Framework
  259. 6-23-92
  260.  
  261. - -- 
  262.  Jamie McCarthy      Internet: k044477@kzoo.edu      AppleLink: j.mccarthy
  263.  Never piss off a computer.
  264.  
  265. ---------------------------
  266.  
  267. From: ejohnson@sunb3.cs.uiuc.edu (Eric E Johnson)
  268. Subject: Does the 68000 have a "block move" instruction
  269. Organization: University of Illinois at Urbana-Champaign
  270. Date: Mon, 22 Jun 1992 18:27:47 GMT
  271.  
  272. I have a 68000 manual, but I have been unable to find a "mass move"
  273. function.  By that, I mean given a starting address, a destination
  274. address, and the number of bytes, the 68000 would busily crank away at
  275. mass moving bytes.  I would have thought that the 68000 had an
  276. instruction like this, but it appears that it does not.  Could anyone
  277. confirm this?
  278.  
  279. - -- 
  280. Eric Johnson               | "The American Republic will endure until the day
  281. ejohnson@suna0.cs.uiuc.edu |  Congress discovers that it can bribe the public
  282. eej37047@uxa.cso.uiuc.edu  |  with the public's money" - Alexis de Toucqueville
  283.  
  284. +++++++++++++++++++++++++++
  285.  
  286. From: philip@pescadero.Stanford.EDU (Philip Machanick)
  287. Date: 22 Jun 92 19:15:47 GMT
  288. Organization: Stanford University
  289.  
  290. In article <1992Jun22.182747.27832@sunb10.cs.uiuc.edu>, ejohnson@sunb3.cs.uiuc.edu (Eric E Johnson) writes:
  291. |> I have a 68000 manual, but I have been unable to find a "mass move"
  292. |> function.  By that, I mean given a starting address, a destination
  293. |> address, and the number of bytes, the 68000 would busily crank away at
  294. |> mass moving bytes.  I would have thought that the 68000 had an
  295. |> instruction like this, but it appears that it does not.  Could anyone
  296. |> confirm this?
  297.  
  298. On a quick check I couldn't find one either but no need to feel
  299. something important is missing.
  300.  
  301. Putting this sort of functionality in hardware is a typical CISC
  302. design flaw that makes it horrendous to implement pipelines
  303. efficiently. The RISC design trade off is to implement the things
  304. that happen often in hardware. The kind of move you want is
  305. relatively rarely used for moving anything more than 4 bytes
  306. but because it takes a variable size of operand, it is hard
  307. to pipeline, and introduces various other nightmares like
  308. handling page faults in the middle of an instruction. All the
  309. effort that goes into dealing with this stuff is much better
  310. put into speeding up things that happen often. [Not just my
  311. opinion : see a good architecture book like Hennessy and
  312. Patterson.]
  313.  
  314. In short: I hope you are right because the absence of such an
  315. instruction means that much more chance that the rumoured
  316. 68060 will be out on time and have decent performance.
  317. - -- 
  318. Philip Machanick
  319. philip@pescadero.stanford.edu
  320.  
  321. +++++++++++++++++++++++++++
  322.  
  323. From: Mark.R.Valence@dartmouth.edu (Mark R. Valence)
  324. Date: 22 Jun 92 22:34:05 GMT
  325. Organization: Dartmouth College, Hanover, NH
  326.  
  327. Well, there are three answers to this question.  The first
  328. (correct/literal) answer is "no, it does not".  See Philip Machanick's
  329. response for a good reason why not (although the problems summarized
  330. are surmountable).
  331.  
  332. The second (Mac specific answer is "but of course".  Here is the code
  333. that does a block move:
  334.  
  335.   MOVEA.L <source-addr>, A0
  336.   MOVEA.L <dest-addr>, A1
  337.   MOVE.L  <length-in-bytes>, D0
  338.   BMOV
  339.  
  340. What you don't have the BMOV Mnemonic in your assembler?  Try opcode
  341. $A02E, commonly known as _BlockMove.
  342.  
  343. The third answer (neat hack/historical relevance) is to use the MOVEM
  344. instruction to quickly move small chunks of data.  This scheme is used
  345. in MacPaint to get quick bitmap movement.  Pretty neat.
  346.  
  347. Mark.
  348.  
  349. +++++++++++++++++++++++++++
  350.  
  351. From: cramer@unixland.natick.ma.us (Bill Cramer)
  352. Date: 23 Jun 92 00:47:28 GMT
  353. Organization: Unixland Public Access Unix  (508) 655-3848
  354.  
  355. ejohnson@sunb3.cs.uiuc.edu (Eric E Johnson) writes:
  356. : I have a 68000 manual, but I have been unable to find a "mass move"
  357. : function.  By that, I mean given a starting address, a destination
  358. : address, and the number of bytes, the 68000 would busily crank away at
  359. : mass moving bytes.  I would have thought that the 68000 had an
  360. : instruction like this, but it appears that it does not.  Could anyone
  361. : confirm this?
  362.  
  363. Yes there is no block move command:-)  The simplest way to perform
  364. a block move is with something like:
  365.  
  366.     movea.l    source,a0
  367.     movea.l dest,a1
  368.     move.l count,d0
  369. label:    move.b (a0)+,(a1)+
  370.     dbne    d0,label
  371.  
  372. which is more or less a strncpy()-type function (excuse the syntax
  373. errors which are no doubt hidden in this code:-).  As someone else
  374. noted, on a 68020 or later processor, these instructions stay in 
  375. the instruction cache, so it gives you the same (or better) speed
  376. as a block move instruction without the microcode penalty. 
  377.  
  378. Bill Cramer
  379.  
  380. 251 West Central Street, Suite 142    | "You can buy better, 
  381. Natick, MA 01760 USA            |    but you just can't pay more."
  382. Internet: cramer@unixland.natick.ma.us    |        
  383. CIS: 70322,3412                | 
  384.  
  385. +++++++++++++++++++++++++++
  386.  
  387. From: zobkiw@world.std.com (Joe Zobkiw)
  388. Date: 23 Jun 92 01:34:11 GMT
  389. Organization: The World Public Access UNIX, Brookline, MA
  390.  
  391. In article <1992Jun22.182747.27832@sunb10.cs.uiuc.edu> ejohnson@sunb3.cs.uiuc.edu (Eric E Johnson) writes:
  392. >I have a 68000 manual, but I have been unable to find a "mass move"
  393. >function.  By that, I mean given a starting address, a destination
  394. >address, and the number of bytes, the 68000 would busily crank away at
  395. >mass moving bytes.  I would have thought that the 68000 had an
  396. >instruction like this, but it appears that it does not.  Could anyone
  397. >confirm this?
  398. >
  399.  
  400. Even the Mac's _BlockMove function simply does a loop of move.l instructions.
  401. That's it!
  402.  
  403.  
  404.  
  405. - -- 
  406. - -- joe zobkiw                      Internet: zobkiw@world.std.com
  407. - --                                      AOL: AFL Zobkiw  
  408. - -- mac.synthesis.MIDI.THINK C.OOP
  409. - -- asm.comm.networks.cool tunes...
  410.  
  411. +++++++++++++++++++++++++++
  412.  
  413. From: rla20@duts.ccc.amdahl.com (Roger Allen)
  414. Date: 23 Jun 92 07:49:31 GMT
  415. Organization: Amdahl Corporation, Sunnyvale CA
  416.  
  417. In article <1992Jun22.191547.14537@CSD-NewsHost.Stanford.EDU> philip@pescadero.stanford.edu writes:
  418. >In article <1992Jun22.182747.27832@sunb10.cs.uiuc.edu>, ejohnson@sunb3.cs.uiuc.edu (Eric E Johnson) writes:
  419. >|> I have a 68000 manual, but I have been unable to find a "mass move"
  420. >|> function.  By that, I mean given a starting address, a destination
  421. >|> address, and the number of bytes, the 68000 would busily crank away at
  422. >|> mass moving bytes.  I would have thought that the 68000 had an
  423. >|> instruction like this, but it appears that it does not.  Could anyone
  424. >|> confirm this?
  425. >
  426. >On a quick check I couldn't find one either but no need to feel
  427. >something important is missing.
  428. >
  429. >Putting this sort of functionality in hardware is a typical CISC
  430. >design flaw that makes it horrendous to implement pipelines
  431. >efficiently. The RISC design trade off...
  432. >
  433. > [blah, blah, blah]
  434. >
  435. >-- 
  436. >Philip Machanick
  437. >philip@pescadero.stanford.edu
  438.  
  439. Ex-squeeze me, did he ask you for a RISC/CISC comparison/contrast? :^)
  440.  
  441. The answer (I have the '030 book right here) is no.
  442.  
  443. Roger
  444.  
  445.  
  446. - --
  447. > Roger Allen                   |  All the opinions expressed are my     <
  448. > Amdahl Computer Development   |  own and have nothing to do with       <
  449. > rla20@cd.amdahl.com           |  Amdahl Corporation.                   <
  450.  
  451. +++++++++++++++++++++++++++
  452.  
  453. From: neeri@iis.ethz.ch (Matthias Neeracher)
  454. Organization: Integrated Systems Laboratory, ETH, Zurich
  455. Date: Tue, 23 Jun 1992 11:31:36 GMT
  456.  
  457. In article <1992Jun23.004728.1707@unixland.natick.ma.us> cramer@unixland.natick.ma.us (Bill Cramer) writes:
  458. >ejohnson@sunb3.cs.uiuc.edu (Eric E Johnson) writes:
  459. >: I have a 68000 manual, but I have been unable to find a "mass move"
  460. >: function.  By that, I mean given a starting address, a destination
  461. >: address, and the number of bytes, the 68000 would busily crank away at
  462. >: mass moving bytes.  I would have thought that the 68000 had an
  463. >: instruction like this, but it appears that it does not.  Could anyone
  464. >: confirm this?
  465. >
  466. >Yes there is no block move command:-)  The simplest way to perform
  467. >a block move is with something like:
  468. >
  469. >    movea.l    source,a0
  470. >    movea.l dest,a1
  471. >    move.l count,d0
  472. >label:    move.b (a0)+,(a1)+
  473. >    dbne    d0,label
  474. >
  475. >which is more or less a strncpy()-type function (excuse the syntax
  476. >errors which are no doubt hidden in this code:-).
  477.  
  478. No syntax errors, as far as I see, but semantic ones: Your loop will terminate
  479. when one of the following three conditions is met:
  480.  
  481. 1) One of the bytes moved is a zero (This is what dbne tests). 
  482. 2) (count MOD 65536)+1 bytes were moved, if count is greater than 65535
  483. 3) count+1 bytes were moved, if count is <= 65535
  484.  
  485. This seems to me a rather conclusive proof that this code will *in no case*
  486. perform the intended thing :-)
  487.  
  488. I agree with a previous poster that the following code is a good idea to use:
  489.  
  490.        LEA     source, A0
  491.        LEA     dest,   A1
  492.        MOVE.L  count,  D0
  493.        _BlockMove
  494.  
  495. Not only is this code more likely to be correct and easier to rectivy if it's
  496. wrong (which I don't want to exclude :-), it is also *faster* for substantial
  497. moves, since _BlockMove uses very carefully unrolled loops (Duff's device and
  498. all that), handles 32 bit counts, and deals correctly with overlapping source
  499. and destination areas. I think the 68030 versions even know how to take
  500. advantage of 16 bytes cache line alignments.
  501.  
  502. The occasions for which hand coded loops might be appropriate are
  503.  
  504. - - If the number of bytes to be moved is usually small
  505. - - If source and destination are non-overlapping
  506. - - If the number of bytes to be moved is constant (copying a ParamBlockRec)
  507. - - If there are conditions for premature termination of the loop (strncpy(), for
  508.   instance).
  509.  
  510. >As someone else
  511. >noted, on a 68020 or later processor, these instructions stay in 
  512. >the instruction cache, so it gives you the same (or better) speed
  513. >as a block move instruction without the microcode penalty. 
  514.  
  515. While it is true that you would have to pay a performance penalty by having a
  516. blockmove instruction, I'd like to point out that, as far as I know, the 680X0
  517. family *is* microcoded, and the instruction cache doesn't cache microcode.
  518.  
  519. Please don't take anything of what I wrote as a flame. We are, after all,
  520. professionals :-)
  521.  
  522. Matthias
  523.  
  524. - -----
  525. Matthias Neeracher                                   neeri@iis.ethz.ch
  526.  "You must have picked up that copy of Scarlett instead of Inside Mac
  527.   when you tried to find the right call..." -- Keith Rollin
  528.  
  529. +++++++++++++++++++++++++++
  530.  
  531. From: Bruce.Hoult@bbs.actrix.gen.nz
  532. Organization: Actrix Information Exchange
  533. Date: Tue, 23 Jun 1992 17:02:09 GMT
  534.  
  535. In article <1992Jun22.182747.27832@sunb10.cs.uiuc.edu> ejohnson@sunb3.cs.uiuc.edu (Eric E Johnson) writes:
  536. > I have a 68000 manual, but I have been unable to find a "mass move"
  537. > function.  By that, I mean given a starting address, a destination
  538. > address, and the number of bytes, the 68000 would busily crank away at
  539. > mass moving bytes.  I would have thought that the 68000 had an
  540. > instruction like this, but it appears that it does not.  Could anyone
  541. > confirm this?
  542.  
  543. It's a little bit of RISC philosophy in a CISC machine -- it only
  544. takes two instructions to write a block move...
  545.  
  546. move.l (a0)+,(a1)+     # or .b or .w or choose other registers
  547. dbra d0, *-4           # or use another register
  548.  
  549. ...and on anything with an instruction cache ('020 and up) or the
  550. "loop mode" in the '010 it will copy memory about as fast as is possible.
  551.  
  552. - -- 
  553. Bruce.Hoult@bbs.actrix.gen.nz   Twisted pair: +64 4 477 2116
  554. BIX: brucehoult                 Last Resort:  PO Box 4145 Wellington, NZ
  555. "Cray's producing a 200 MIPS personal computer with 64MB RAM and a 1 GB
  556. hard disk that fits in your pocket!"   "Great!  Is it PC compatable?"
  557.  
  558. +++++++++++++++++++++++++++
  559.  
  560. From: stu5s11@bcrka280.bnr.ca 
  561. Organization: Bell-Northern Research, Ottawa, Canada
  562. Date: Tue, 23 Jun 1992 17:45:11 GMT
  563.  
  564.  
  565. Like the previous messages say, there is no block move
  566. on the 68000.  The closest thing that there would be is
  567. the use of DBcc loop on a 68010, which uses a small
  568. instruction cache (3 bytes) to keep the entire loop on
  569. chip, allow a fast blockmove.
  570.  
  571. The only other instruction close to a block move is on the
  572. 68040, that has a MOVE16 instruction that takes advantage
  573. of a burst read to transfer 16 bytes at once.
  574.  
  575. The reason for not having a block move instruction has also
  576. already been explained.  It's not worth it to use up extra
  577. hardware for no increase in speed.
  578.  
  579. For example, once during a 6502 vs. Z80 debate, (Ah..
  580. the good old days before 040 vs. 486 debates) someone
  581. mentioned the block move instruction on the Z80.
  582. I then proceeded to write a 6502 routine that used less
  583. cycles than the Z80 hardware instruction.
  584.  
  585. - ----------------------------------------------------------
  586. John Andrusiak
  587.  
  588.  
  589. +++++++++++++++++++++++++++
  590.  
  591. From: nagle@netcom.com (John Nagle)
  592. Date: Tue, 23 Jun 92 17:15:20 GMT
  593. Organization: Netcom - Online Communication Services  (408 241-9760 guest) 
  594.  
  595. ejohnson@sunb3.cs.uiuc.edu (Eric E Johnson) writes:
  596. >I have a 68000 manual, but I have been unable to find a "mass move"
  597. >function.  By that, I mean given a starting address, a destination
  598. >address, and the number of bytes, the 68000 would busily crank away at
  599. >mass moving bytes.  I would have thought that the 68000 had an
  600. >instruction like this, but it appears that it does not.  Could anyone
  601. >confirm this?
  602.  
  603.         Most if not all 680x0 implementations provide "loop mode".
  604. This mechanism treats two-instruction loops where the loop instruction
  605. is a DBcc as a special case, so that the instructions remain in the
  606. CPU without being refetched from memory as the loop executes.  Thus,
  607. all the memory bandwidth can be devoted to the instruction being
  608. repeatedly executed.  So a MOVE followed by a DBcc will produce the
  609. effect of a "mass move" instruction.
  610.  
  611.         Still, loop unrolling may be faster.
  612.  
  613.         I have yet to see a 68000 compiler smart enough to generate a two
  614. instruction loop, though, even though it is quite possible with current
  615. compiler technology.
  616.  
  617.                     John Nagle
  618.  
  619. +++++++++++++++++++++++++++
  620.  
  621. From: suitti@ima.isc.com (Stephen Uitti)
  622. Organization: Interactive Systems, Cambridge, MA 02138-5302
  623. Date: Tue, 23 Jun 1992 23:14:36 GMT
  624.  
  625. In article <1992Jun23.174511.14555@bcrka451.bnr.ca> stu5s11@bcrka280.bnr.ca  writes:
  626. >
  627. >Like the previous messages say, there is no block move
  628. >on the 68000.  The closest thing that there would be is
  629. >the use of DBcc loop on a 68010, which uses a small
  630. >instruction cache (3 bytes) to keep the entire loop on
  631. >chip, allow a fast blockmove.
  632. >
  633. >The only other instruction close to a block move is on the
  634. >68040, that has a MOVE16 instruction that takes advantage
  635. >of a burst read to transfer 16 bytes at once.
  636. >
  637. >The reason for not having a block move instruction has also
  638. >already been explained.  It's not worth it to use up extra
  639. >hardware for no increase in speed.
  640. >
  641. >For example, once during a 6502 vs. Z80 debate, (Ah..
  642. >the good old days before 040 vs. 486 debates) someone
  643. >mentioned the block move instruction on the Z80.
  644. >I then proceeded to write a 6502 routine that used less
  645. >cycles than the Z80 hardware instruction.
  646.  
  647. In the days of 6502 vs Z80, there were fewer devices on the chip
  648. that these days.  Most (but not all) cycles had to do with
  649. loading data from memory or storing it to memory.  Two byte long
  650. instructions generally took twice as long as one byte
  651. instructions.  Each memory reference takes another cycle per
  652. byte.  The Z80 block move instruction is two bytes.  It loads a
  653. byte via one pointer, stores it via another, increments both
  654. pointers, decrements a count, and checks the count for zero.  If
  655. the count is not zero, the Z80 decremented the PC by 2 (which
  656. effectively means that the instruction was really a tight loop).
  657. Thus, the instruction was read for each byte transfered.  I don't
  658. recall if the 6502 had two byte loads and stores to speed things
  659. up, but loop unrolling can certainly help.  Also, Z80 cycles do
  660. not compare one-to-one with 6502 cycles.  For a 2 MHz Z80, you
  661. needed 1 MHz memory.  For a 1 MHz 6502, you needed 1 MHz memory.
  662. Thus, there was roughly a two to one difference in cycle counts.
  663. I remember a claim that with the 8085 undocumented extension of
  664. the extra status flag conditional jump instructions, you could
  665. outperform a 4 MHz Z80 with a 5 MHz 8085.  This was sort of fair,
  666. in that you could not yet buy a 5 MHz Z80.  I don't believe that
  667. the 6502 outperformed a Z80 on block move when using memory of
  668. the same speed.  The Z80 instruction could have been implemented
  669. in fewer cycles - who knows, maybe the Z100 did that.  I found
  670. that most block copies were short on the Z80, and so performance
  671. wasn't really an issue.  Maybe it was just for my code, for my
  672. applications, under my operating system.  I seldom worked with
  673. more than a byte at a time.
  674.  
  675. Of course, this is architectual trivia that has nothing to do
  676. with a Mac.  _Blockmove is hard to beat for portability and speed
  677. on a Mac.
  678.  
  679. Stephen.
  680. suitti@ima.isc.com
  681.  
  682. +++++++++++++++++++++++++++
  683.  
  684. From: suitti@ima.isc.com (Stephen Uitti)
  685. Organization: Interactive Systems, Cambridge, MA 02138-5302
  686. Date: Tue, 23 Jun 1992 23:20:49 GMT
  687.  
  688. In article <s4qlwtf.nagle@netcom.com> nagle@netcom.com (John Nagle) writes:
  689. >        I have yet to see a 68000 compiler smart enough to generate a two
  690. >instruction loop, though, even though it is quite possible with current
  691. >compiler technology.
  692.  
  693. I was very surprized not to see DBxx instructions from Think C.
  694. This is a compiler that produces very good code, in general.
  695. However, when I actually attempted to use DBxx using ASM statements,
  696. I found it to have all sorts of unusual side effects.  I was unable
  697. to determine what they were from the manaul, or how to code with them
  698. by hand.  Very, very odd.  I didn't spend THAT much time working
  699. on it, however.
  700.  
  701. Stephen.
  702.  
  703. +++++++++++++++++++++++++++
  704.  
  705. From: lsh1@ra.msstate.edu (Shane Hebert)
  706. Date: 24 Jun 92 00:31:34 GMT
  707. Organization: Mississippi State University
  708.  
  709. suitti@ima.isc.com (Stephen Uitti) writes:
  710.  
  711. >In article <s4qlwtf.nagle@netcom.com> nagle@netcom.com (John Nagle) writes:
  712. >>        I have yet to see a 68000 compiler smart enough to generate a two
  713. >>instruction loop, though, even though it is quite possible with current
  714. >>compiler technology.
  715.  
  716.  
  717. I may have gotten in a little late on this conversation but using the
  718. movem.l instruction on the 68000 can move 16 longwords with one instruction.
  719.  
  720.     movem.l    SOURCE,d0-d7/a0-a7
  721.     movem.l    d0-d7/a0-a7,DEST
  722.  
  723. works fairly well if you don't mind the destruction of the register
  724. contents.  Even then you can use this instruction to save all the
  725. registers before moving the block of memory.
  726.  
  727. hebert@erc.msstate.edu
  728.  
  729. +++++++++++++++++++++++++++
  730.  
  731. From: potts@itl.itd.umich.edu (Paul Potts)
  732. Date: 24 Jun 92 15:00:24 GMT
  733. Organization: Instructional Technology Laboratory, University of Michigan
  734.  
  735. In article <1992Jun22.191547.14537@CSD-NewsHost.Stanford.EDU> philip@pescadero.stanford.edu writes:
  736. >In article <1992Jun22.182747.27832@sunb10.cs.uiuc.edu>, ejohnson@sunb3.cs.uiuc.edu (Eric E Johnson) writes:
  737. >|> I have a 68000 manual, but I have been unable to find a "mass move"
  738. >|> function.  By that, I mean given a starting address, a destination
  739. >|> address, and the number of bytes, the 68000 would busily crank away at
  740. >|> mass moving bytes.  I would have thought that the 68000 had an
  741. >|> instruction like this, but it appears that it does not.  Could anyone
  742. >|> confirm this?
  743. >
  744.  
  745. You're right, there is no "block move" instruction. There are good reasons
  746. not to implement it that have been mentioned. These instructions are nice to
  747. have for some purposes - I remember using the block move on the Z-80 processor,
  748. with much success - but they don't have a place in a processor which must
  749. respond quickly to interrupts. Instructions should generally always be
  750. "atomic" and uninterruptible (for example, it is critical that there is
  751. a test and set instruction which executes atomically in order to implement
  752. semaphores.) A single instruction shouldn't be interruptible (able?) because
  753. you would need excessive logic for state recovery. If the user wants to block-
  754. move ten thousand bytes using a single instruction, you have effectively
  755. locked out interrupt handling for a lot of cycles, which has a great potential
  756. to cause very subtle error conditions (loss of network packets, serial line
  757. characters, "heartbeat" functionality, etc.)
  758.  
  759.  
  760. - -- 
  761. The essence of OOP: "With all this horse manure, I know there's got to be
  762.                      a pony in here somewhere!"
  763. Paul R. Potts, Software Designer --- potts@itl.itd.umich.edu <--- me!
  764.  
  765. +++++++++++++++++++++++++++
  766.  
  767. From: Sherman@128.147.155.27 (Sherman Uitzetter)
  768. Date: 24 Jun 92 15:57:13 GMT
  769. Organization: NMRI Pittsburgh
  770.  
  771. In article <1992Jun23.212101.18059@bcrka451.bnr.ca> ,
  772. stu5s11@bcrka280.bnr.ca writes:
  773. >Based on what I've heard microcode, is not only on it's way out,
  774. >it's long gone. I believe that the 68040 uses microcode only in
  775. >limited amounts, or not at all.
  776.  
  777.  
  778.    I'm quite sure this is incorrect.  Microcode is definately here
  779. to stay - even on RISC processors.  Today's processors are simply
  780. much too complicated to be "hard-wired."
  781.    I could see where nanocode might not be used on RISC processors
  782. since, by design, the processor is simple enough to do everything
  783. with microcode.
  784.  
  785.  
  786. - -Sherman.
  787.  
  788. +++++++++++++++++++++++++++
  789.  
  790. From: ephraim@think.com (Ephraim Vishniac)
  791. Date: 24 Jun 92 17:53:18 GMT
  792. Organization: Thinking Machines Corporation, Cambridge MA, USA
  793.  
  794. In article <1992Jun24.150024.21047@terminator.cc.umich.edu> potts@itl.itd.umich.edu (Paul Potts) writes:
  795. >You're right, there is no "block move" instruction. There are good reasons
  796. >not to implement it that have been mentioned. These instructions are nice to
  797. >have for some purposes - I remember using the block move on the Z-80 processor,
  798. >with much success - but they don't have a place in a processor which must
  799. >respond quickly to interrupts. Instructions should generally always be
  800. >"atomic" and uninterruptible (for example, it is critical that there is
  801. >a test and set instruction which executes atomically in order to implement
  802. >semaphores.) A single instruction shouldn't be interruptible (able?) because
  803. >you would need excessive logic for state recovery. 
  804.  
  805. The Z80's block instructions did not lock out interrupts, nor did they
  806. "need excessive logic for state recovery." The reason is that these
  807. instructions were actually single-instruction loops. Each execution of
  808. the instruction only moved one byte. So, interrupt latency remained
  809. short - an interrupt could perfectly well be handled while a block
  810. instruction loop was in progress. 
  811.  
  812. In the Z80, I think the block move instructions (LDIR, LDDR, OTIR,
  813. INIR, and others I've doubtless forgotten) were an excellent idea
  814. because a limited address space made code density extremely important.
  815. Now that address spaces are large and memory is cheap, things look
  816. different. 
  817.  
  818. - -- 
  819. Ephraim Vishniac    ephraim@think.com   ThinkingCorp@applelink.apple.com
  820.  Thinking Machines Corporation / 245 First Street / Cambridge, MA 02142
  821.         One of the flaws in the anarchic bopper society was
  822.         the ease with which such crazed rumors could spread.
  823.  
  824. +++++++++++++++++++++++++++
  825.  
  826. From: des7f@fulton.seas.Virginia.EDU (David E. Sappington)
  827. Organization: University of Virginia
  828. Date: Wed, 24 Jun 1992 18:58:50 GMT
  829.  
  830. potts@itl.itd.umich.edu (Paul Potts) writes:
  831. >You're right, there is no "block move" instruction. There are good reasons
  832. >not to implement it that have been mentioned. These instructions are nice to
  833. >have for some purposes - I remember using the block move on the Z-80 processor,
  834. >with much success - but they don't have a place in a processor which must
  835. >respond quickly to interrupts. Instructions should generally always be
  836. >"atomic" and uninterruptible (for example, it is critical that there is
  837. >a test and set instruction which executes atomically in order to implement
  838. >semaphores.) A single instruction shouldn't be interruptible (able?) because
  839. >you would need excessive logic for state recovery. If the user wants to block-
  840. >move ten thousand bytes using a single instruction, you have effectively
  841. >locked out interrupt handling for a lot of cycles, which has a great potential
  842. >to cause very subtle error conditions (loss of network packets, serial line
  843. >characters, "heartbeat" functionality, etc.)
  844. >
  845.  
  846. Instructions on the 68010 and higher are not necessarily atomic.  The CPU
  847. deals with this by putting extra information on the stack in response to
  848. an exception (aka interrupt) thus allowing the CPU to "continue" the
  849. interrupted instruction rather than "restart" it. A good example of all
  850. this occurs when an instruction requires something from a virtual memory
  851. page that is not currently resident in RAM.
  852.  
  853. Dave Sappington                     des7f@virginia.edu
  854. Institute for Parallel Computation  des7f@virginia.bitnet
  855. University of Virginia
  856.  
  857.  
  858. +++++++++++++++++++++++++++
  859.  
  860. From: potts@itl.itd.umich.edu (Paul Potts)
  861. Date: 24 Jun 92 20:01:09 GMT
  862. Organization: Instructional Technology Laboratory, University of Michigan
  863.  
  864. In article <1992Jun24.185850.21424@murdoch.acc.Virginia.EDU> des7f@fulton.seas.Virginia.EDU (David E. Sappington) writes:
  865. >potts@itl.itd.umich.edu (Paul Potts) writes:
  866. >
  867. >Instructions on the 68010 and higher are not necessarily atomic.  The CPU
  868. >deals with this by putting extra information on the stack in response to
  869. >an exception (aka interrupt) thus allowing the CPU to "continue" the
  870. >interrupted instruction rather than "restart" it. 
  871.  
  872. OK, I've gotten corrected from a number of people (some by mail and some
  873. by news). I was wrong. I guess that comes from the fact that the last 
  874. processor I studied in detail was the 68000 (and I never studied the Z80 in
  875. detail, just programmed it some). Sorry about that. I was aware of the way
  876. the stack frame is used to handle exceptions on the 68000, but apparently
  877. the mechanism has been extended since then. Progress - go figure! : /
  878.  
  879. - -- 
  880. The essence of OOP: "With all this horse manure, I know there's got to be
  881.                      a pony in here somewhere!"
  882. Paul R. Potts, Software Designer --- potts@itl.itd.umich.edu <--- me!
  883.  
  884. +++++++++++++++++++++++++++
  885.  
  886. From: paul@taniwha.UUCP (Paul Campbell)
  887. Date: 29 Jun 92 07:49:09 GMT
  888. Organization: Taniwha Systems Design
  889.  
  890. In article <1992Jun22.223405.7704@dartvax.dartmouth.edu> Mark.R.Valence@dartmouth.edu (Mark R. Valence) writes:
  891. >Well, there are three answers to this question.  The first
  892. >(correct/literal) answer is "no, it does not".  See Philip Machanick's
  893. >
  894. >The second (Mac specific answer is "but of course".  Here is the code
  895. >$A02E, commonly known as _BlockMove.
  896. >
  897. >The third answer (neat hack/historical relevance) is to use the MOVEM
  898.  
  899. and maybe a fourth - on most 68k varients a :
  900.  
  901. @1:    move.l    (a0)+, (a1)+
  902.     dbra    d0, @1
  903.  
  904. loop fits in the cache and probably executes as fast as the microcode to
  905. do a block-move instruction on many other CPUs - with any good memory system
  906. it's going to be memory bandwidth bound
  907.  
  908.     Paul
  909.  
  910.  
  911. - -- 
  912. Paul Campbell    UUCP: ..!mtxinu!taniwha!paul     AppleLink: CAMPBELL.P
  913.  
  914.     "'Potato', not 'Potatoe'"
  915.         Bart Simpson - on the blackboard 6/25/92
  916.  
  917. +++++++++++++++++++++++++++
  918.  
  919. From: paul@taniwha.UUCP (Paul Campbell)
  920. Date: 29 Jun 92 14:47:51 GMT
  921. Organization: Taniwha Systems Design
  922.  
  923. In article <NEERI.92Jun23123136@iis.ethz.ch> neeri@iis.ethz.ch (Matthias Neeracher) writes:
  924. >
  925. >I agree with a previous poster that the following code is a good idea to use:
  926. >
  927. >       LEA     source, A0
  928. >       LEA     dest,   A1
  929. >       MOVE.L  count,  D0
  930. >       _BlockMove
  931. >
  932. >Not only is this code more likely to be correct and easier to rectivy if it's
  933. >wrong (which I don't want to exclude :-), it is also *faster* for substantial
  934.  
  935. On an '040 Mac Apple have patched _BlockMove to flush the cache - this takes a
  936. while and slows everything down thereafter. Untill Apple provides us with
  937. _BlockMoveNoCache you SHOULD write your own _BlockMove and NOT use the one
  938. provided. Just to be pedantic:
  939.  
  940.     lea    source, a0
  941.     lea    dest, a1
  942.     move.l    count, d0
  943.     sub.l    #1, d0
  944.     move.l    d0, d1
  945.     swap    d1
  946.     tst.w    d1
  947.     beq.s    @3
  948. @1:        move.l    #$ffff, d2
  949. @2:            move.b    (a0)+, (a1)+
  950.             dbra    d2, @2
  951.         dbra    d1, @1
  952.     
  953. @3:        move.b    (a0)+, (a1)+
  954.         dbra    d0, @3
  955.  
  956.     should do it
  957.  
  958.     Paul
  959.  
  960. - -- 
  961. Paul Campbell    UUCP: ..!mtxinu!taniwha!paul     AppleLink: CAMPBELL.P
  962.  
  963.     "'Potato', not 'Potatoe'"
  964.         Bart Simpson - on the blackboard 6/25/92
  965.  
  966. +++++++++++++++++++++++++++
  967.  
  968. From: neeri@iis.ethz.ch (Matthias Neeracher)
  969. Organization: Integrated Systems Laboratory, ETH, Zurich
  970. Date: Wed, 1 Jul 1992 10:23:09 GMT
  971.  
  972. In article <1134@taniwha.UUCP> paul@taniwha.UUCP (Paul Campbell) writes:
  973. >In article <NEERI.92Jun23123136@iis.ethz.ch> neeri@iis.ethz.ch (Matthias Neeracher) writes:
  974. >>
  975. >>I agree with a previous poster that the following code is a good idea to use:
  976. >>
  977. >>       LEA     source, A0
  978. >>       LEA     dest,   A1
  979. >>       MOVE.L  count,  D0
  980. >>       _BlockMove
  981. >>
  982. >>Not only is this code more likely to be correct and easier to rectivy if it's
  983. >>wrong (which I don't want to exclude :-), it is also *faster* for substantial
  984. >
  985. >On an '040 Mac Apple have patched _BlockMove to flush the cache - this takes a
  986. >while and slows everything down thereafter.
  987.  
  988. As far as I know, flushing the cache is relatively fast. You're right that this
  989. slows things down a little, though. But that doesn't excuse the following
  990. NONSENSE (sorry, there *is* no other word for it):
  991.  
  992. >Untill Apple provides us with
  993. >_BlockMoveNoCache you SHOULD write your own _BlockMove and NOT use the one
  994. >provided.
  995.  
  996. WRONG! _BlockMove is still more correct than 95% of all memory move routines I
  997. have seen posted here, and for substantial moves, it is faster than 100% of
  998. them. Your code is proof of both of these claims:
  999.  
  1000. >Just to be pedantic:
  1001. >
  1002. >    lea    source, a0
  1003. >    lea    dest, a1
  1004. >    move.l    count, d0
  1005. >    sub.l    #1, d0
  1006. >    move.l    d0, d1
  1007. >    swap    d1
  1008. >    tst.w    d1
  1009. >    beq.s    @3
  1010. >@1:        move.l    #$ffff, d2
  1011. >@2:            move.b    (a0)+, (a1)+
  1012. >            dbra    d2, @2
  1013. >        dbra    d1, @1
  1014. >    
  1015. >@3:        move.b    (a0)+, (a1)+
  1016. >        dbra    d0, @3
  1017. >
  1018. >    should do it
  1019.  
  1020. No, it doesn't.
  1021.  
  1022. - - Your code is *incorrect*. Try it with count>=65537.
  1023. - - Your code is *horrendously inefficient*. I don't have a '040 and a few
  1024.   weeks of spare time to measure the typical effects of a cache flush, but
  1025.   if you think they are worse than replacing _BlockMove (which I heard uses
  1026.   MOVE16 on an '040, provided the alignment is right) with a non-unrolled
  1027.   byte moving loop, you are most likely mistaken.
  1028.  
  1029. Matthias
  1030.  
  1031. PS: Excuse me if I sound too harsh, but arguments involving presumed
  1032.     "performance gain" are an especially addictive trap for programmers
  1033.     to fall into, so posting incorrect code in these cases is IMHO a lot
  1034.     worse.
  1035.  
  1036. - -----
  1037. Matthias Neeracher                                   neeri@iis.ethz.ch
  1038.  "A lot of heavy-metal kids are just plain dumb." -- Chris Novoselic
  1039.  
  1040. +++++++++++++++++++++++++++
  1041.  
  1042. From: d88-jwa@dront.nada.kth.se (Jon W{tte)
  1043. Organization: Royal Institute of Technology, Stockholm, Sweden
  1044. Date: Wed, 1 Jul 1992 10:41:18 GMT
  1045.  
  1046. .UUCP> paul@taniwha.UUCP (Paul Campbell) writes:
  1047.  
  1048.    while and slows everything down thereafter. Untill Apple provides us with
  1049.    _BlockMoveNoCache you SHOULD write your own _BlockMove and NOT use the one
  1050.    provided. Just to be pedantic:
  1051.  
  1052. Yes ! I don't like this over-caution approach Apple has towards
  1053. protecting people who do strange things to code (like the
  1054. Segment Loader :-)
  1055.  
  1056.    nit picking:
  1057.  
  1058.    @2:            move.b    (a0)+, (a1)+
  1059.  
  1060.    @3:        move.b    (a0)+, (a1)+
  1061.  
  1062. More nits to pick:
  1063.  
  1064. But... these are byte moves ! You could special-case for
  1065. both source and destination being even, or both being odd,
  1066. and use longword moves. Maybe even special-case for source
  1067. & destination being the same modulo 16 and use MOVE16...
  1068.  
  1069. - -- 
  1070.          Jon W{tte, Svartmangatan 18, S-111 29 Stockholm, Sweden
  1071.  
  1072.  "Difficult, obscure, incoherent and nonstandard does not imply more power."
  1073.                - Andrew Kass in comp.sys.mac.hardware
  1074.  
  1075. +++++++++++++++++++++++++++
  1076.  
  1077. From: bruner@sp15.csrd.uiuc.edu (John Bruner)
  1078. Date: 1 Jul 92 14:59:39 GMT
  1079. Organization: CSRD, University of Illinois
  1080.  
  1081. In article <NEERI.92Jul1112309@iis.ethz.ch> neeri@iis.ethz.ch (Matthias Neeracher) writes:
  1082. > WRONG! _BlockMove is still more correct than 95% of all memory move routines I
  1083. > have seen posted here, and for substantial moves, it is faster than 100% of
  1084. > them. Your code is proof of both of these claims:
  1085.  
  1086. The most efficient way to move memory depends upon many factors; thus,
  1087. it is hard to get it right.  The best sequence depends upon the
  1088. alignment of the operands, the size of the move, the processor,
  1089. whether cache invalidation is to be an issue, etc.  This is one of the
  1090. reasons that it is expensive in terms of development time and
  1091. transistors to put it in the instruction set: all of the special cases
  1092. must be handled properly.
  1093.  
  1094. On all processors it will be most efficient if loads and stores are
  1095. aligned on natural boundaries.  Otherwise the processor must use
  1096. multiple bus cycles to load or store unaligned data.  If the processor
  1097. has a cache then some of this effect can be hidden, but in the case of
  1098. write-through cache you still will pay for two write cycles if you
  1099. write longword data at an address that is not a multiple of four.  If
  1100. possible, align both operands (e.g., if the source is N+n and the
  1101. destination is M+n, where N and M are multiples of 4, use something
  1102. like Duff's device or a small MOVE.B/DBRA loop to move the first (4-n)
  1103. bytes and then use MOVE.L to move the bulk of the bytes.  (Fix up the
  1104. end, as necessary, with a few more byte moves.)
  1105.  
  1106. The easiest case is the 68010, where data moves from odd to even
  1107. addresses or vice versa pretty much have to be done with a MOVE.B/DBRA
  1108. loop and other moves are most efficient with MOVE.L/DBRA.  Loop mode
  1109. eliminates the need for the instruction fetches, which overcomes any
  1110. potential efficiency you could otherwise gain by unrolling the loop.
  1111. Of course, no Macintosh products use the 68010, so this doesn't help
  1112. much.
  1113.  
  1114. Likewise, on the 68000, data moves from odd to even addresses or vice
  1115. versa call for a MOVE.B/DBRA loop.  Copy longwords in an unrolled loop
  1116. to minimize the loop overhead.  I don't recall the timing of DBRA on
  1117. the 68000, but it may even be the case that it doesn't pay to use it
  1118. and you might as well use a single MOVE.L/SUBQ/Bxx loop rather than
  1119. a nested MOVE.L/DBRA/DBRA one.
  1120.  
  1121. For the 680[23]0, align the destination at a multiple of four and then
  1122. copy longwords.  Unroll the loop to minimize the loop overhead.
  1123.  
  1124. I don't know enough about the 68040 to come up with the best strategy.
  1125. MOVE16 probably will help quite a bit, so you probably want to align
  1126. the operands on a cache line boundary.
  1127.  
  1128. The boundary conditions for these cases get messy, particularly if
  1129. you want to copy in ascending or descending order in order to handle
  1130. overlapped moves correctly.  For all of these reasons, unless you have
  1131. a very special case, _BlockMove is likely to be a better alternative.
  1132. - --
  1133. (Dr.) John Bruner, Deputy Director            bruner@csrd.uiuc.edu
  1134. Center for Supercomputing Research & Development    (217) 244-4476 (voice)
  1135. University of Illinois at Urbana-Champaign        (217) 244-1351 (FAX)
  1136. 305 Talbot Laboratory; 104 South Wright St.; Urbana, IL  61801
  1137.  
  1138. ---------------------------
  1139.  
  1140. End of C.S.M.P. Digest
  1141. **********************
  1142.